import {ActionContext} from 'vuex'
interface IState{
    count:number
}
export default{
    namespaced:true,
    //vuex4版本的state是一个函数,返回的返回值中定义store中的state的初始数据
    state:():IState=>{
        return{
            count:0
        }
    },
    mutations:{
        INCREMENT(state:IState,payload:number){
            state.count+=payload
        }
    },
    actions:{
        incrementAsync(context:ActionContext<IState,any>,payload:number){
            setTimeout(() => {
                context.commit("INCREMENT",payload)
            }, 3000);
        }
    }
}